{% extends "base.html" %}
{% block title %} show all the papers {% endblock %}
{% block style %}
	<script type="text/javascript">
	$(document).ready(function () {
		$("#t_title").autocomplete(
			'/ajax/title/autocomplete/',
			{multiple:true,multipleSeparator:' '}
			);
		});
	function go_t_page(){
		var t_page=document.getElementById("t_page").value; 
		var loc = "/paper/?page="
		loc=loc.concat(t_page);
		//for test: alert(loc);
		window.location=loc;
	};
	function go_t_title(){
		var t_title=document.getElementById("t_title").value; 
		var loc = "/paper/?title="
		loc=loc.concat(t_title);
		window.location=loc;
	};
	</script>
{% endblock %}
{% block _title %} <h1> All the Papers </h1> {% endblock %}

{% block content %}
	<div id="search_paper_by_title" align="center">
		<font color="gray"> 想找哪篇？	
		<input type="text" size="32" id="t_title" name="title"/>
		</font>
	<input type="submit" value="找一下!" onclick="go_t_title();" /> 
	</div>
	<br/>
	{% if count %}
		{{ count }} papers found.<br/>
		<ul>
			<font color="gray">	
			{% for paper in papers.object_list %}
			<!-- Changed in Django Development version: Previously, you would need to use \{\% for contact in contacts.object_list \%\}, since the Page object was not iterable. -->
				<li> <a href="{{ paper.get_ab_url }}" > {{ paper.title }} </a>(created by <a href="/people/{{ paper.first_au.id }}">{{ paper.first_au }} </a>
			
			{% if paper.other_au.all %} and	{% for au in paper.other_au.all %}<a href="/people/{{ au.id }}">{{ au }} </a>	{% endfor %} {% endif %}

			@{{ paper.pub_date|date:"Y-m" }}) </i>
			{% endfor%}
		
		</font>
		</ul>	
	
	<hr/>
		<div class="paginator"	>
			{% if papers.has_previous %}
				<a href="?page={{ papers.previous_page_number }}">&laquo;Pervious</a>
			{% endif %}
			<span class="current">
				Page {{ papers.number }} of {{ papers.paginator.num_pages }}
			</span>
			{% if papers.has_next %}
				<a href="?page={{ papers.next_page_number }}">Next &raquo;</a>
			{% endif %}
		|	<font color="gray">  想更快？何不试试跳楼 :)  
				<input type="text" size="2" id="t_page"/></font> <input type="submit" value="扑通一下" onclick="go_t_page();"/>
		</div>	
	{% else %}
		no paper found.
	{% endif %}
{%	endblock %}

